﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using ThreeByte.ActiveDeck.Config;
using ThreeByte.ActiveDeck.Content;

namespace ThreeByte.ActiveDeck.AddIn.Config.Properties
{
    public enum ActionType { PageLink, LayerAction };

    public class ShapePropertiesBinder : DependencyObject
    {
        private readonly Microsoft.Office.Interop.PowerPoint.Shape Shape;

        public ShapePropertiesBinder(PowerPoint.Shape shape) {
            Shape = shape;

            //Parse the current tags into appropriate properties
            if(!(string.IsNullOrEmpty(shape.Tags[PropertyTags.LAYER_ACTION]))) {
                this.Action = ActionType.LayerAction;
                this.Layer = SlideUtil.ParseLayerAction(shape.Tags[PropertyTags.LAYER_ACTION]).LayerTarget;
            } else if(!(string.IsNullOrEmpty(shape.Tags[PropertyTags.PAGE_LINK]))) {
                this.Action = ActionType.PageLink;
                this.Page = int.Parse(shape.Tags[PropertyTags.PAGE_LINK]);
            }
        }


        #region Dependency Properties
        public static readonly DependencyProperty ActionProperty = DependencyProperty.Register("Action",
            typeof(ActionType), typeof(ShapePropertiesBinder), new FrameworkPropertyMetadata(ActionType.PageLink, ActionChanged));

        [ActiveDeckProperty]
        public ActionType Action {
            get {
                return (ActionType)GetValue(ActionProperty);
            }
            set {
                SetValue(ActionProperty, value);
            }
        }

        private static void ActionChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) {
            
        }

        public static readonly DependencyProperty PageProperty = DependencyProperty.Register("Page",
            typeof(int), typeof(ShapePropertiesBinder), new FrameworkPropertyMetadata(PageChanged));

        [ActiveDeckProperty]
        public int Page {
            get {
                return (int)GetValue(PageProperty);
            }
            set {
                SetValue(PageProperty, value);
            }
        }

        private static void PageChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) {
            //Set the tag value appropriately

        }

        public static readonly DependencyProperty LayerProperty = DependencyProperty.Register("Layer",
            typeof(int), typeof(ShapePropertiesBinder), new FrameworkPropertyMetadata(LayerChanged));

        [ActiveDeckProperty]
        public int Layer {
            get {
                return (int)GetValue(LayerProperty);
            }
            set {
                SetValue(LayerProperty, value);
            }
        }

        private static void LayerChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) {
            //Set the tag value appropriately

        }



        #endregion Dependency Properties

    }
}
